/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.agendajedi.dominio;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Lee Majors Jedi
 */
@Entity
@Table(name = "contatos")
@NamedQueries({@NamedQuery(name = "Contatos.findAll", query = "SELECT c FROM Contatos c")})
public class Contato implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "idContato")
    private Integer idContato;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Column(name = "empresa")
    private String empresa;
    @Column(name = "dataAniversario")
    @Temporal(TemporalType.DATE)
    private Date dataAniversario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idContato")
    private Collection<MeioContato> meioContatoCollection;
    @JoinColumn(name = "idUsuario", referencedColumnName = "idUsuario")
    @ManyToOne
    private Usuario idUsuario = new Usuario();
    @OneToMany(mappedBy = "idContato")
    private Collection<Endereco> enderecoCollection;

    public Contato() {
    }

    public Contato(Integer idContato) {
        this.idContato = idContato;
    }

    public Contato(Integer idContato, String nome) {
        this.idContato = idContato;
        this.nome = nome;
    }

    public Integer getIdContato() {
        return idContato;
    }

    public void setIdContato(Integer idContato) {
        this.idContato = idContato;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEmpresa() {
        return empresa;
    }

    public void setEmpresa(String empresa) {
        this.empresa = empresa;
    }

    public Date getDataAniversario() {
        return dataAniversario;
    }

    public void setDataAniversario(Date dataAniversario) {
        this.dataAniversario = dataAniversario;
    }

    public Collection<MeioContato> getMeioContatoCollection() {
        return meioContatoCollection;
    }

    public void setMeioContatoCollection(Collection<MeioContato> meioContatoCollection) {
        this.meioContatoCollection = meioContatoCollection;
    }

    public Usuario getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuario idUsuario) {
        this.idUsuario = idUsuario;
    }

    public Collection<Endereco> getEnderecoCollection() {
        return enderecoCollection;
    }

    public void setEnderecoCollection(Collection<Endereco> enderecoCollection) {
        this.enderecoCollection = enderecoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContato != null ? idContato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contato)) {
            return false;
        }
        Contato other = (Contato) object;
        if ((this.idContato == null && other.idContato != null) || (this.idContato != null && !this.idContato.equals(other.idContato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dominio.Contatos[idContato=" + idContato + "]";
    }

}
